package com.sdi.columbus;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.json.JSONException;
import org.json.JSONObject;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

import android.util.Log;

public class GetReport {
	
	 public String GetValues(String accountID,String vehicleid, String startt,String endt) throws ClientProtocolException, IOException, JSONException
	    {
	    	
	    	String result="";
	    	GpsData gps=new GpsData();
//	    	int custid=gps.getCustomerId();
//	    	String userID=gps.getUserID();
//	    	String accountID=gps.getAccountID();
//	    	accountID=ColombusApp.getSharedApp().accountId;
	    	
//	    	System.out.println("frm report i am user:"+userID);
	    	System.out.println("frm report i am customer:"+accountID);
	    	System.out.println("frm report i am vehicle:"+vehicleid);
	    	System.out.println("frm report startt"+startt);
	    	System.out.println("frm report i endt:"+endt);
	    	// Add your data
	    	
	    	JSONObject user =  new JSONObject();
//	    	user.put("userID",String.valueOf(userID));
	    	user.put("accountID",accountID);
//	    	user.put("accountID",String.valueOf(custid));
	    	user.put("vehicleID",String.valueOf(vehicleid));
	    	user.put("startTime",startt);
	    	user.put("endTime",endt);
	    	
	    	// Create a new HttpClient and Post Header
	    	
	    	HttpClient client = new DefaultHttpClient();
	    	URI website;
			try {
				website = new URI("http://deepam.cloudapp.net/ColumbusRESTService/ColumbusREST.svc/json/GetTripSummary");
				HttpPost request = new HttpPost();
		    	request.setEntity(new StringEntity(user.toString()));
		    	request.addHeader("content-type", "application/json");      
		    	request.setURI(website);
		    	
		    	// Execute HTTP Post Request
		    	HttpResponse response = client.execute(request);
		    	HttpEntity entity = response.getEntity();
				result = EntityUtils.toString(entity);
		    	

		    	System.out.println("Report values"+result);
			} catch (URISyntaxException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
	    	
	    	
			return result; 	
	    	
	    	
	    }    


	

}
